import { Select } from 'antd'
import React, { Component } from 'react'
import { getChannels } from 'api/channels'

export default class index extends Component {
  state = {
    channels: []
  }
  componentDidMount() {
    this.getChannels()
  }
  // 获取所有频道列表
  getChannels = async () => {
    const {
      data: { channels }
    } = await getChannels()
    this.setState({
      channels
    })
  }
  render() {
    // console.log(this.props)

    return (
      <Select
        // defaultValue="lucy"
        style={{
          width: 200
        }}
        value={this.props.value}
        onChange={this.props.onChange}
        allowClear
        placeholder="请选择文章频道"
        options={this.state.channels.map((item) => {
          return { label: item.name, value: item.id }
        })}
      />
    )
  }
}
